package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.order.domain.SrvFeedbform;
import com.ruoyi.order.service.ISrvFeedbformService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 办理单Controller
 * 
 * @author ruoyi
 * @date 2021-01-29
 */
@RestController
@RequestMapping("/feedbform")
public class SrvFeedbformController extends BaseController
{
    @Autowired
    private ISrvFeedbformService srvFeedbformService;

    /**
     * 查询办理单列表
     */
    @PreAuthorize(hasPermi = "system:feedbform:list")
    @GetMapping("/list")
    public TableDataInfo list(SrvFeedbform srvFeedbform)
    {
        startPage();
        List<SrvFeedbform> list = srvFeedbformService.selectSrvFeedbformList(srvFeedbform);
        return getDataTable(list);
    }

    /**
     * 导出办理单列表
     */
    @PreAuthorize(hasPermi = "system:feedbform:export")
    @Log(title = "办理单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrvFeedbform srvFeedbform) throws IOException
    {
        List<SrvFeedbform> list = srvFeedbformService.selectSrvFeedbformList(srvFeedbform);
        ExcelUtil<SrvFeedbform> util = new ExcelUtil<SrvFeedbform>(SrvFeedbform.class);
        util.exportExcel(response, list, "feedbform");
    }

    /**
     * 获取办理单详细信息
     */
    @PreAuthorize(hasPermi = "system:feedbform:query")
    @GetMapping(value = "/{srvFbcode}")
    public AjaxResult getInfo(@PathVariable("srvFbcode") String srvFbcode)
    {
        return AjaxResult.success(srvFeedbformService.selectSrvFeedbformById(srvFbcode));
    }

    /**
     * 新增办理单
     */
    @PreAuthorize(hasPermi = "system:feedbform:add")
    @Log(title = "办理单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrvFeedbform srvFeedbform)
    {
        return toAjax(srvFeedbformService.insertSrvFeedbform(srvFeedbform));
    }

    /**
     * 修改办理单
     */
    @PreAuthorize(hasPermi = "system:feedbform:edit")
    @Log(title = "办理单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SrvFeedbform srvFeedbform)
    {
        return toAjax(srvFeedbformService.updateSrvFeedbform(srvFeedbform));
    }

    /**
     * 删除办理单
     */
    @PreAuthorize(hasPermi = "system:feedbform:remove")
    @Log(title = "办理单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{srvFbcodes}")
    public AjaxResult remove(@PathVariable String[] srvFbcodes)
    {
        return toAjax(srvFeedbformService.deleteSrvFeedbformByIds(srvFbcodes));
    }
}
